package user

import (
	"gitee.com/tbq_go_packages/utils"
	"github.com/savsgio/atreugo"
)

type UserController struct {
}

func (uc UserController) Login(ctx *atreugo.RequestCtx) error {
	username := string(ctx.FormValue("username"))
	password := string(ctx.FormValue("password")) //支持post和get

	db := utils.GetDb("mysql", "root:111111@tcp(localhost:3306)/hyperf_usercenter?charset=utf8")
	sql := "select `password`,id from users where account=?"
	row := db.SelectOne(sql, username)
	var passwordDB string
	var id int64
	row.Scan(&passwordDB, &id)
	if password == password {
		return ctx.JSONResponse(atreugo.JSON{"msg": "登录成功"})
	} else {
		return ctx.JSONResponse(atreugo.JSON{"msg": "登录失败"})
	}
}
